package org.example.HspTank;

import org.example.TankGan.Recorder;
import org.example.TankGan.service.PanelTank;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @author cc
 * @date 2021/4/17 11:36
 * @Description 坦克大战的界面大小
 */
//JFrame窗体
public class HspTankGame01 extends JFrame {

    //定义PanelTank
    PanelTank pt=null;
    public static void main(String[] args) {
        HspTankGame01 hspTankGame01 = new HspTankGame01();
    }
   public HspTankGame01() {
       pt = new PanelTank();
       Thread thread = new Thread(pt);
       thread.start();
        this.add(pt);//把面板放入
       this.setSize(1320,750);
       this.addKeyListener(pt);
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       this.setVisible(true);

       Recorder.read();
       //设置一个关闭时候的监听
       this.addWindowListener(new WindowAdapter() {
           @Override
           public void windowClosing(WindowEvent e) {
               super.windowClosing(e);
               Recorder.save();
           }
       });
   }
}
